
(defun sh (cmd)
    #+clisp
        (let ((str (ext:run-shell-command cmd :output :stream)))
            (loop for line = (read-line str nil)
             until (null line)
             do (print line)))
    #+ecl 
        (si:system cmd)
    #+sbcl 
        (sb-ext:run-program "/bin/sh" (list "-c" cmd) :input nil :output *standard-output*)
    #+clozure 
    (ccl:run-program "/bin/sh" (list "-c" cmd) :input nil :output *standard-output*))

(define (sh-com com-str &optional (res-type 'str)(res-deli #\newline))
    (let ((fp (ext:run-shell-command com-str :output :stream)))
      (let ((res nil)(s (read-line fp nil)))
	(loop (when (null s) (return res))
	   (cond ((eql res-type 'str)
		  (cond ((eql res-deli #\space) (setf res (concatenate 'string res  s (string #\space))))
			((eql res-deli #\newline) (setf res (concatenate 'string res s (string #\newline)))) ))
		 ((eql res-type 'list) (setf res (concatenate 'list res (list s))))
		 (t (format t "非预订返回类型。[~a]~%" res-type)))
	   (setf s (read-line fp nil))))))
